| Conditions | 2 | 
| Total Lines | 27 | 
| Code Lines | 22 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import {QueryHandler} from '@nestjs/cqrs'; | ||
| 15 | |||
| 16 | public async execute( | ||
| 17 | query: GetProjectsQuery | ||
| 18 |   ): Promise<Pagination<ProjectView>> { | ||
| 19 |     const {customerId, page} = query; | ||
| 20 | |||
| 21 | const projectViews: ProjectView[] = []; | ||
| 22 | const [projects, total] = await this.projectRepository.findProjects( | ||
| 23 | page, | ||
| 24 | customerId | ||
| 25 | ); | ||
| 26 | |||
| 27 |     for (const project of projects) { | ||
| 28 | const customer = project.getCustomer(); | ||
| 29 | |||
| 30 | projectViews.push( | ||
| 31 | new ProjectView( | ||
| 32 | project.getId(), | ||
| 33 | project.getName(), | ||
| 34 | project.getDayDuration(), | ||
| 35 | project.getInvoiceUnit(), | ||
| 36 | new CustomerView(customer.getId(), customer.getName()) | ||
| 37 | ) | ||
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | return new Pagination<ProjectView>(projectViews, total); | ||
| 42 | } | ||
| 44 |